import java.io.IOException;

import reader.InstanceReader;
import reader.ResultReader;
import reader.SolutionReader;
import value_object.InstanceVO;
import value_object.ResultVO;
import value_object.SolutionVO;
import factory.ResultFactory;
import factory.SolutionFactory;

/**
 * This is the main application class
 * 
 */

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		int data_set_number = 2, grid_number = 9,  track_number = 170;
		
		InstanceReader instanceReader = new InstanceReader();
		InstanceVO instance = new InstanceVO();
		
		System.out.println("-----------------------------------------");
		System.out.println("           Instance information          "); 
		System.out.println("-----------------------------------------");
		
		//read instance 		
		instance = instanceReader.readInstance(data_set_number, grid_number, track_number);
		System.out.println(instance);
		
		System.out.println("-----------------------------------------");
		System.out.println("            Solution information         "); 
		System.out.println("-----------------------------------------");
		
		/**
		 * create the solution from an instance
		 */
		SolutionFactory solutionFac = new SolutionFactory(instance);
		SolutionVO solution = solutionFac.getSolution();
		System.out.println(solution);		
		
		//write solution to file
		SolutionReader solutionReader = new SolutionReader();
		solutionReader.writeSolution(solution);
		
		System.out.println("-----------------------------------------");
		System.out.println("            Result information           "); 
		System.out.println("-----------------------------------------");
		
		/**
		 * create the result from an solution
		 */		
		ResultFactory resultFac = new ResultFactory(instance);
		ResultVO result = resultFac.getResult(solution);
		System.out.println(result);
		
		//write result to file
		ResultReader resultReader = new ResultReader();
		resultReader.writeResult(result);
		
		System.out.println("================================UPDATE=====================================");
		SolutionVO solutionUpdated = solutionFac.updateSolution(solution);
		System.out.println("Solution updated:");
		System.out.println(solutionUpdated);
		
		System.out.println("Result updated:");
		ResultVO resultUpdated = resultFac.getResult(solutionUpdated);
		System.out.println(resultUpdated);
		
		//Test 
		
	}	
}
